package tron

import (
	"context"
	"tronServer/utility/tron"

	"tronServer/api/tron/v1"
)

// TronTrxBalanceQuery 查询Trx余额
func (c *ControllerV1) TronTrxBalanceQuery(ctx context.Context, req *v1.TronTrxBalanceQueryReq) (res *v1.TronTrxBalanceQueryRes, err error) {
	var (
		balance string
	)
	// 检查钱包
	{
		if err = tron.Tron.CheckTrc20Address(ctx, req.Trc20Address); err != nil {
			return
		}
	}
	// 获取余额
	{
		if balance, err = tron.Query.GetTrxBalance(ctx, req.Trc20Address); err != nil {
			return
		}
	}
	// 返回数据
	res = &v1.TronTrxBalanceQueryRes{
		TrxBalance: balance,
	}
	return
}
